// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   pk1.YCCtbl.java

package MaintMenu.VenPricingUpdMasterFiles;

import javax.swing.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class AP
{

    public AP()

    {
        int cc=0;
        int counter=1;
        int x=0;
        int y=0;
        try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String dataSourceName = "dbLI";
            String dbURL = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName).toString();
            Connection conli = DriverManager.getConnection(dbURL, "", "");
            //Statement stli = conli.createStatement();



//            String dataSourceName6 = "dbBL";
//            String dbURL6 = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName6).toString();
//            Connection conbk = DriverManager.getConnection(dbURL6, "", "");
//            Statement stbk1 = conbk.createStatement();
//            Statement stbk2 = conbk.createStatement();
//            Statement stbk3 = conbk.createStatement();

            //Here is where you enter SQL Statements

            //clean up fields

            String st[] = new String[18];
            st[0] = ("UPDATE tblbcn SET gd_p=null, [gd#]=null, gd_c=null, gd_k=null");
            st[1] = ("UPDATE tblhfn SET gd_p=null, [gd#]=null, gd_c=null, gd_k=null");
            st[2] = ("UPDATE tblotn SET gd_p=null, [gd#]=null, gd_c=null, gd_k=null");
//            System.out.printf("step : %d complete", counter);
            counter++;

            //clean up MASTER Category file
            st[3] = ("UPDATE bcmast SET gd_no=null");
            st[4] = ("UPDATE hfmast SET gd_no=null");
            st[5] = ("UPDATE otmast SET gd_no=null");
//            System.out.printf("step : %d complete", counter);
            counter++;




            //update Vendor part# on BCMAST master file using PARTLINK #.
            st[6] = ("UPDATE bcmast as a INNER JOIN _costap1 as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.capa=true and b.capa='y';");
            st[7] = ("UPDATE bcmast as a INNER JOIN _costap1 as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE (a.capa is null or 'n') and b.capa is null;");
//            System.out.printf("step : %d complete", counter);
            counter++;


            //update Vendor part# on HFMAST master file using PARTLINK #.
            st[8] = ("UPDATE hfmast as a INNER JOIN _costap1 as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.capa=true and b.capa='y';");
            st[9]= ("UPDATE hfmast as a INNER JOIN _costap1 as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE (a.capa is null or 'n') and b.capa is null;");
//            System.out.printf("step : %d complete", counter);
            counter++;


            //update Vendor part# on OTMAST master file using PARTLINK #.
            st[10]= ("UPDATE otmast as a INNER JOIN _costap1 as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE a.capa=true and b.capa='y';");
            st[11]= ("UPDATE otmast as a INNER JOIN _costap1 as b on a.partlink=b.prtlnk SET a.gd_no = b.ap WHERE ((a.capa is null or 'n') or 'n') and b.capa is null;");
//            System.out.printf("step : %d complete", counter);
            counter++;





            //update Vendor Pricing using PARTLINK#
            st[12]= ("UPDATE bcmast AS a INNER JOIN _costap1 AS b ON a.partlink = b.prtlnk SET a.part_no=b.oem, a.gd_prc = b.upx, a.gd_no =b.ap, a.gd_pkg = b.[std p/k], a.gd_cuft = b.cuftper WHERE (a.capa is null or 'n') AND b.CAPA is null;");
//            System.out.printf("step : %d complete", counter);
            counter++;

            st[13]= ("UPDATE bcmast AS a INNER JOIN _costap1 AS b ON a.partlink = b.prtlnk SET a.part_no=b.oem, a.gd_prc = b.upx, a.gd_no =b.ap, a.gd_pkg = b.[std p/k], a.gd_cuft = b.cuftper WHERE a.capa=true AND b.CAPA='y';");
//            System.out.printf("step : %d complete", counter);
            counter++;

            st[14]= ("UPDATE hfmast AS a INNER JOIN _costap1 AS b ON a.partlink = b.prtlnk SET a.part_no=b.oem, a.gd_prc = b.upx, a.gd_no =b.ap, a.gd_pkg = b.[std p/k], a.gd_cuft = b.cuftper WHERE (a.capa is null or 'n') AND b.CAPA is null;");
//            System.out.printf("step : %d complete", counter);
            counter++;

            st[15]= ("UPDATE hfmast AS a INNER JOIN _costap1 AS b ON a.partlink = b.prtlnk SET a.part_no=b.oem, a.gd_prc = b.upx, a.gd_no =b.ap, a.gd_pkg = b.[std p/k], a.gd_cuft = b.cuftper WHERE a.capa=true AND b.CAPA='y';");
//            System.out.printf("step : %d complete", counter);
            counter++;

            st[16]= ("UPDATE otmast AS a INNER JOIN _costap1 AS b ON a.partlink = b.prtlnk SET a.part_no=b.oem, a.gd_prc = b.upx, a.gd_no =b.ap, a.gd_pkg = b.[std p/k], a.gd_cuft = b.cuftper WHERE (a.capa is null or 'n') AND b.CAPA is null;");
//            System.out.printf("step : %d complete", counter);
            counter++;

            st[17]= ("UPDATE otmast AS a INNER JOIN _costap1 AS b ON a.partlink = b.prtlnk SET a.part_no=b.oem, a.gd_prc = b.upx, a.gd_no =b.ap, a.gd_pkg = b.[std p/k], a.gd_cuft = b.cuftper WHERE a.capa=true AND b.CAPA='y';");
//            System.out.printf("step : %d complete", counter);

            counter++;





            for (x=0; x<st.length;x++){
                Statement stli = conli.createStatement();

                try {

                    int rowsupdated = stli.executeUpdate(st[x]);
//                    System.out.println(st[x]);
                    System.out.print("TRU : "+rowsupdated+"\t");
                    //JOptionPane.showOptionDialog(null, "Statement : " + st[x] + "\n\nTotal record Updated : " + rowsupdated, "Update Complete", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new Object[]{}, null);
                    cc++;
                    if (cc==4){
                        System.out.println("");
                        cc=0;
                    }

                }catch(SQLException er) {
                    er.printStackTrace();
                }stli.close();
            }



//            stbk1.close();
//            stbk2.close();
//            stbk3.close();
            conli.close();
//            conbk.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}
